import request from '@/plugins/axios'

export function query(query){
    return request({
        url: '/api/propertybasic/page',
        method: 'get',
        params: query
    })
}

export function save(data){
    return request.post('/api/propertybasic', data)
}

export function remove(ids){
    return request({
        url: '/api/propertybasic/delete',
        method: 'post',
        data: ids
    })
}
export function validateProjectCode(param){
    return request({
        url: '/api/propertybasic/validateProjectCode',
        method: 'get',
        params: param
    })
}

export function get(projectId){
    return request({
        url: '/api/propertybasic/' + projectId,
        method: 'get'
    })
}
export function getAddress(projectId){
    return request({
        url: '/api/propertybasic/getAddress/' + projectId,
        method: 'get'
    })
}

export function update(data){
    return request({
        url: '/api/propertybasic',
        method: 'put',
        data: data
    })
}
//文件列表接口
export function getFiles(id, moduleId) {
    return request({
        url: '/admin/sys-file/getFileList/' + id + '/' + moduleId,
        method: 'get'
    })
}
//判断文件是否存在
export function checkFiles(id) {
    return request({
        url: '/admin/sys-file/checkFileIsNot/' + id,
        method: 'get'
    })
}
//删除文件
export function delFiles(id, moduleId) {
    return request({
        url: '/admin/sys-file/delFileByFileId/' + id + '/' + moduleId,
        method: 'delete'
    })
}

/**
 * 获取所有有效项目列表
 * @returns {*}
 */
export function getAllProject() {
    return request.get("/api/propertybasic/getAllProject")
}

export function validateProject(query){
    return request({
        url: '/api/rentproperty/validateProject',
        method: 'get',
        params: query
    })
}

//配套信息编辑删除
export function removeFacById(id) {
    return request({
        url: '/api/propertybasic/removeFacById/' + id,
        method: 'delete'
    })
}
//里程碑初始化
export function initMilestones(query) {
    return request({
        url: '/api/underconstruction/initMilestones',
        method: 'get',
        params: query
    })
}
//验证配套设施物业是否重复，0可用，1不可用  参数有roomName：物业名称 必填 facId：配套设施ID 非必填
export function validateFacRoomName(query){
    return request({
        url: '/api/roominfo/validateFacRoomName',
        method: 'get',
        params: query
    })
}

/**
 * 验证项目国家编码是否存在
 * @param query
 */
export function validateProjectCountryCode(code, id) {
    return request({
        url: '/api/propertybasic/validateProjectCountryCode',
        method: 'get',
        params: {"projectCountryCode": code, "projectId": id}
    })
}
